Set my CPAN install directory
May 25, 2004 9:04 PM Subscribe
I want the CPAN shell to install modules it's done building to a directory other than /usr/lib/perl5blahetc (largely because I am not root on this particular server and won't be). This being perl I'd be _highly_ surprised if there's no way to set the installation directory, but a quick perusal of the CPAN shell settings gives no such option. Nor does a similarly quick perusal of ~/.cpan/.
Sometimes I find a similar problem when trying to build perl moduels by hand... it just seems to *assume* that I want to install to /usr/lib/perl5yaddayadda when I type make install. How do I control this stuff?
Sometimes I find a similar problem when trying to build perl moduels by hand... it just seems to *assume* that I want to install to /usr/lib/perl5yaddayadda when I type make install. How do I control this stuff?
Oh, and when building by hand you can just do "perl Makefile.PL PREFIX=/home/you/lib/perl5" before you "make" and "make install".
posted by nicwolff at 9:56 PM on May 25, 2004
posted by nicwolff at 9:56 PM on May 25, 2004
Oh! And apparently you can set up a personal MyConfig.pm as described in this article, which is full of good tips about running Perl and Apache without root privileges.
posted by nicwolff at 10:15 PM on May 25, 2004
posted by nicwolff at 10:15 PM on May 25, 2004
Response by poster: Thanks nicwolff -- o conf works pretty well. The exception seems to be if you end up trying to build something that has uninstalled dependencies... in which case the CPAN shell carps because it doesn't know /home/me/local/perlhooplah should be in @INC.
To fix this, I tried:
perl -MCPAN -e shell -I/home/me/local/perlhooplah
but this didn't seem to work.
Other techniques? (Sorry if it's in the article -- I did read it, and it's way cool, but I couldn't extract this particular bit of wisdom from it...)
posted by namespan at 11:29 PM on May 25, 2004
To fix this, I tried:
perl -MCPAN -e shell -I/home/me/local/perlhooplah
but this didn't seem to work.
Other techniques? (Sorry if it's in the article -- I did read it, and it's way cool, but I couldn't extract this particular bit of wisdom from it...)
posted by namespan at 11:29 PM on May 25, 2004
Here's the relevant part of that article:
-----
When you start the
the user's private configuration file and then for the system-wide
one. When I'm logged as user
If there is no
the shell for the first time it will ask you a dozen configuration
questions and then create the Config.pm file for you.
If you already have it system-wide configured, then you should have a
Perl version, then alter the path to use your Perl's version number when
looking up the file. Create the directory (
whole path at once) where the local configuration file will go:
Now copy the system wide configuration file to your local one.
The only thing left is to change the base directory of .cpan in
your local file to the one under your home directory. On my machine, I
replace
resides) with
Now you have the local configuration file ready, you have to tell it
what special parameters you need to pass when executing the
Open the file in your favorite editor and replace line:
with:
Now you've finished the configuration. Assuming that you are logged
in as the same user you have prepared the local installation for
(stas in our example), start it like this:
From now on, any module you try to install will be installed locally.
If you need to install some system modules, then just become the superuser
and install them in the same way. When you are logged in as the
superuser, the system-wide configuration file will be used instead of
your local one.
posted by nicwolff at 6:32 AM on May 26, 2004 [1 favorite]
-----
When you start the
CPAN
interactive shell, it searches first forthe user's private configuration file and then for the system-wide
one. When I'm logged as user
stas
, the two files on my setup are:
/home/stas/.cpan/CPAN/MyConfig.pm
/usr/lib/perl5/5.00503/CPAN/Config.pm
If there is no
CPAN
shell configured on your system, then when you startthe shell for the first time it will ask you a dozen configuration
questions and then create the Config.pm file for you.
If you already have it system-wide configured, then you should have a
/usr/lib/perl5/5.00503/CPAN/Config.pm
. If you have a differentPerl version, then alter the path to use your Perl's version number when
looking up the file. Create the directory (
mkdir -p
creates thewhole path at once) where the local configuration file will go:
% mkdir -p /home/stas/.cpan/CPAN
Now copy the system wide configuration file to your local one.
% cp /usr/lib/perl5/5.00503/CPAN/Config.pm \
/home/stas/.cpan/CPAN/MyConfig.pm
The only thing left is to change the base directory of .cpan in
your local file to the one under your home directory. On my machine, I
replace
/usr/src/.cpan
(that's where my system's .cpan
directoryresides) with
/home/stas
. I use Perl, of course!
% perl -pi -e 's|/usr/src|/home/stas|' \
/home/stas/.cpan/CPAN/MyConfig.pm
Now you have the local configuration file ready, you have to tell it
what special parameters you need to pass when executing the
perl
Makefile.PL
stage.Open the file in your favorite editor and replace line:
'makepl_arg' => q[],
with:
'makepl_arg' => q[PREFIX=/home/stas],
Now you've finished the configuration. Assuming that you are logged
in as the same user you have prepared the local installation for
(stas in our example), start it like this:
% perl -MCPAN -e shell
From now on, any module you try to install will be installed locally.
If you need to install some system modules, then just become the superuser
and install them in the same way. When you are logged in as the
superuser, the system-wide configuration file will be used instead of
your local one.
posted by nicwolff at 6:32 AM on May 26, 2004 [1 favorite]
This thread is closed to new comments.
cpan> o conf makepl_arg 'PREFIX=/home/you/lib/perl5'
cpan> install whatever
should do what you want.
posted by nicwolff at 9:53 PM on May 25, 2004